/*		Filename: 	card_manager.h
 *		Author:		彭望
 *		Date:		2012-01-10
 *		Use:		定义卡管理系统的结构
 */

#ifndef CARD_MANAGER_H
#define CARD_MANAGER_H

#include "public.h"
#include "card_info.h"
#include "database_manager.h"
#include "logger.h"

class CCardManager
{
		public:
				CCardManager(const DBManagerPtr& m_dbPtr);
				//新增卡
				RetCode_t add_card(const CCardInfo&) const;
				//删除卡
				RetCode_t delete_card(const CCardInfo& ) const;
				//查询卡信息,以info中cardId为key查找，返回值填充info
				RetCode_t search_card(CCardInfo& ) const;
				//更改卡的信息
				RetCode_t update_card(const CCardInfo& info) const;
				//验证卡的信息合法性
				RetCode_t check_card(const CCardInfo& ) const;

#if 0
				//增加余额（充值),delta >= 0
				RetCode_t add_balance(const CCardInfo& info, double delta) const;
				//扣除余额 (扣费), delta <= 0
				RetCode_t cut_balance(const CCardInfo& info, double delta) const;
				//以info中cardId为Key,查找结果并填充info
				RetCode_t query_balance(CCardInfo& info) const;
#endif

				static bool isDigits(const string& );
				static bool hasInvalidCharactor(const string& );
		private:
				DBManagerPtr m_dbPtr;
				log4cpp::Category& logger;

};

typedef boost::shared_ptr<CCardManager> CCardManagerPtr;
#endif
